/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import com.sun.org.apache.xml.internal.security.utils.Base64;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author antonio
 */
public class Digest {
    
    public static String digest(String string, String digestAlgorithm) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        byte[] plainText = string.getBytes("UTF8");
        MessageDigest md = MessageDigest.getInstance(digestAlgorithm);
        md.update(plainText);
        byte[] digest = md.digest();
        return Base64.encode(digest);
    }
    
}
